/**
 * Copyright (c) 2010 BullionXpress.com,
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */
package com.bullionxpress.shared.model;

import java.awt.Color;
import java.io.Serializable;
import java.util.Date;

/**
 *
 * @author BullionXpress.com
 */
public class Tick implements Serializable {
    public transient static long NOT_SPECIFIED = -1;
    private long id = NOT_SPECIFIED;

    transient private Instrument instrument = null;
    transient static final Color borderColorHC = Color.green;
    transient static final Color borderColorLC = Color.red;
    transient static final Color highCloseColor = Color.green;
    transient static final Color lowCloseColor = Color.red;
    transient static final Color highlightedColor = Color.yellow;

    transient public boolean highlighted = false;
    
    private long timestamp;
    public double open;
    public double high;
    public double low;
    public double close;
    public long volume;

    public Color getBorderColor() {
        if (highlighted) {
            return highlightedColor;
        }
        if (open <= close) {
            return borderColorHC;
        } else {
            return borderColorLC;
        }
    }

    public Color getColor() {
        Color col = null;
        if (open <= close) {
            col = highCloseColor;
        } else {
            col = lowCloseColor;
        }
        if (highlighted) {
            return highlightedColor;
        }
        return col;
    }

    /**
     * @return the timestamp
     */
    public long getTimestamp() {
        return timestamp;
    }

    /**
     * @param timestamp the timestamp to set
     */
    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    /**
     * @return the open
     */
    public double getOpen() {
        return open;
    }

    /**
     * @param open the open to set
     */
    public void setOpen(double open) {
        this.open = open;
    }

    /**
     * @return the high
     */
    public double getHigh() {
        return high;
    }

    /**
     * @param high the high to set
     */
    public void setHigh(double high) {
        this.high = high;
    }

    /**
     * @return the low
     */
    public double getLow() {
        return low;
    }

    /**
     * @param low the low to set
     */
    public void setLow(double low) {
        this.low = low;
    }

    /**
     * @return the close
     */
    public double getClose() {
        return close;
    }

    /**
     * @param close the close to set
     */
    public void setClose(double close) {
        this.close = close;
    }

    /**
     * @return the volume
     */
    public long getVolume() {
        return volume;
    }

    /**
     * @param volume the volume to set
     */
    public void setVolume(long volume) {
        this.volume = volume;
    }

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * @return the instrument
     */
    public Instrument getInstrument() {
        return instrument;
    }

    /**
     * @param instrument the instrument to set
     */
    public void setInstrument(Instrument instrument) {
        this.instrument = instrument;
    }

    public String toString()
    {
        return "id:" + id + " instrument:" + instrument + " o:" + open + " h:" + high + " l:" + low + " c:" + close + " ts:" + timestamp;
    }
}
